package com.youdo.service;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 视频数据
 *
 * @author ljb
 * @date 2025.06.20
 * @email 568838953@qq.com
 */
public class BufferWrapper implements Parcelable {
    private byte[] hb;// 
    private int frameId;// 帧id
    private int length;// 长度

    // Constructor
    public BufferWrapper(byte[] hb, int frameId, int length) {
        this.hb = hb;
        this.frameId = frameId;
        this.length = length;
    }

    // Getter and Setter methods
    public byte[] getHb() {
        return hb;
    }

    public void setHb(byte[] hb) {
        this.hb = hb;
    }

    public int getFrameId() {
        return frameId;
    }

    public void setFrameId(int frameId) {
        this.frameId = frameId;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    // Parcelable implementation
    protected BufferWrapper(Parcel in) {
        // Read the byte array
        hb = in.createByteArray();
        // Read the frameId
        frameId = in.readInt();
        // Read the chunkId
        length = in.readInt();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        // Write the byte array
        dest.writeByteArray(hb);
        // Write the frameId
        dest.writeInt(frameId);
        // Write the chunkId
        dest.writeInt(length);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    // This is used to regenerate your object. All Parcelables must have a CREATOR that implements this interface.
    public static final Parcelable.Creator<BufferWrapper> CREATOR = new Parcelable.Creator<BufferWrapper>() {
        @Override
        public BufferWrapper createFromParcel(Parcel in) {
            return new BufferWrapper(in);
        }

        @Override
        public BufferWrapper[] newArray(int size) {
            return new BufferWrapper[size];
        }
    };

    @Override
    public String toString() {
        return "{frameId=" + frameId +
                ", chunkId=" + length +
                '}';
    }
}